#!/bin/bash

cd /
image=$1

v1=`hsc version | grep Release | cut -f3 -d" "`
v2=`hsc version | grep Version | cut -f3 -d" "`
vers=`echo $v1.$v2`

if [ $vers != "3.2.6" ]; then
   echo "Incompatible Update. Updates not installed"
   exit 2
fi

if [ -f $image/hsc.tar ]
then
   echo "--- Installing CIM/miscellaneous updates..." |tee -a  $logFile
   cd /
   tar -xf $image/hsc.tar
   if [ $? -ne 0 ]
   then
      exit 6
   fi
   chmod 555 /usr/lib/libBPAClient.so
   chown bin:bin /usr/lib/libBPAClient.so
   tar -tf $image/hsc.tar | sed -e 's/^.//' > /opt/hsc/data/extbackupfile.list
fi

echo "PLEASE REBOOT YOUR SYSTEM IN ORDER TO COMMIT THE CHANGES....."

if [ -f $image/.VERSION ]
then
  cat $image/.VERSION >> /root/.version
  cat $image/.VERSION >> /home/hscroot/.version
  cat $image/.VERSION >> /opt/hsc/data/version
  chmod 644 /home/hscroot/.version
  chown hscroot.HSC_Sys_Prog /home/hscroot/.version
fi

exit 0
